package top.zhuyougu.demo1.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.zhuyougu.demo1.Mapper.CourseMapper;
import top.zhuyougu.demo1.pojo.Course;

import java.util.List;

@Slf4j
@Service
public class CourseService {
    @Autowired
    private CourseMapper courseMapper;
    public List<Course> findAll(){
        return courseMapper.selectList(new LambdaQueryWrapper<>());
    }
    public List<Course> findPage(int current  ,int pageSize){
        Page<Course> page = new Page<>(current,pageSize);
        Page<Course> coursePage = courseMapper.selectPage(page, new LambdaQueryWrapper<>());
        log.info("total:{}",coursePage.getTotal());
        log.info("pages:{}",coursePage.getPages());
        return coursePage.getRecords();
    }


}
